#include "CMoveCommand.h"
#include "CUserInterface.h"
#include "CLevelEditor.h"
#include "ISceneManager.h"
#include "ISceneNode.h"
#include "CSceneObject.h"

extern CGlobals* g;
extern CUserInterface* ui;
extern CLevelEditor* editor;

CMoveCommand::CMoveCommand (int id, vector3df oldPosition, vector3df newPosition)
{
	m_id = id;
	m_oldPosition = oldPosition;
	m_newPosition = newPosition;
	stringw name = editor->getSceneObjectFromID(id)->m_UserData->getAttributeAsStringW("Name");
	setDescription(stringw(L"move ") + name + L"(" + stringw(id) + L")");
}

void CMoveCommand::redo ()
{
	g->sceneManager->getSceneNodeFromId(m_id)->setPosition(m_newPosition);
}

void CMoveCommand::undo ()
{
	g->sceneManager->getSceneNodeFromId(m_id)->setPosition(m_oldPosition);
}
